package com.errol.batchprocessor.employeeaddition.advisorimpl.common.payload;

import com.renjia.entity.CoreAgreementDetail;
import com.renjia.entity.CoreEmployee;
import com.renjia.entity.CoreEmployeeCustomer;
import com.renjia.entity.CoreUserBank;
import com.renjia.enums.DocumentTypeEnum;
import com.renjia.service.generic.middleware.batchprocessor.payload.AbstractSinglePayload;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 人员导入批处理业务 单条数据抽象类
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2021/03/01
 * @since v5.0.6
 **/
@Getter
public abstract class AbstractEmployeeSinglePayload<SE> extends AbstractSinglePayload<SE> {

    /**
     * 导入的人员原始数据
     */
    private final String employeeName;
    private final DocumentTypeEnum documentTypeEnum;
    private final String documentNumber;
    private final String rawBankCard;
    private final String rawMobile;
    /**
     * @since v5.2.6 允许自动补全银行卡和手机号，重写getter方法
     */
    private String autoCompleteBankCard;
    private String autoCompleteMobile;
    /**
     * 验证错误信息
     */
    private final List<String> errMsgList;

    private CoreEmployee coreEmployee;
    private CoreEmployeeCustomer coreEmployeeCustomer;
    private CoreUserBank coreUserBank;
    private CoreAgreementDetail coreAgreementDetail;
    /**
     * 手机号是否未被使用：默认 true 未被使用
     */
    private boolean mobileUnique;
    /**
     * true 表示需要写入手机号（新增时手机号未重复、编辑时手机号变更且未重复）；默认 false
     */
    private boolean mobileModified;
    /**
     * 三要素接口验证结果，null 表示未验证
     */
    private Boolean isThreeElementSuccess;
    private String bankCardBranchNo;
    /**
     * 已存在 coreEmployee，原实名未认证，本次通过了实名认证，为 true ，需要更新已存在 employeeCustomer
     */
    private Boolean existEmployeeIdentityAuthed;

    public AbstractEmployeeSinglePayload(SE singleEntity, String employeeName, DocumentTypeEnum documentTypeEnum, String documentNumber, String bankCard, String mobile) {
        super(singleEntity);
        this.employeeName = employeeName;
        this.documentTypeEnum = documentTypeEnum;
        this.documentNumber = documentNumber.toUpperCase();
        this.rawBankCard = bankCard == null ? null: bankCard.replace(" ", "");
        this.rawMobile = mobile;
        this.errMsgList = new ArrayList<>();
        this.mobileUnique = true;
        this.mobileModified = false;
        this.isThreeElementSuccess = null;
    }

    public String getBankCard() {
        return rawBankCard == null ? autoCompleteBankCard : rawBankCard;
    }

    public String getMobile() {
        return rawMobile == null ? autoCompleteMobile : rawMobile;
    }

    public void setAutoCompleteBankCard(String autoCompleteBankCard) {
        this.autoCompleteBankCard = autoCompleteBankCard;
    }

    public void setAutoCompleteMobile(String autoCompleteMobile) {
        this.autoCompleteMobile = autoCompleteMobile;
    }

    public void setCoreEmployee(CoreEmployee coreEmployee) {
        this.coreEmployee = coreEmployee;
    }

    public void setCoreEmployeeCustomer(CoreEmployeeCustomer coreEmployeeCustomer) {
        this.coreEmployeeCustomer = coreEmployeeCustomer;
    }

    public void setCoreUserBank(CoreUserBank coreUserBank) {
        this.coreUserBank = coreUserBank;
    }

    public void setCoreAgreementDetail(CoreAgreementDetail coreAgreementDetail) {
        this.coreAgreementDetail = coreAgreementDetail;
    }

    public void setMobileUnique(boolean mobileUnique) {
        this.mobileUnique = mobileUnique;
    }

    public void setMobileModified(boolean mobileModified) {
        this.mobileModified = mobileModified;
    }

    public void setThreeElementSuccess(boolean threeElementSuccess) {
        isThreeElementSuccess = threeElementSuccess;
    }

    public void setBankCardBranchNo(String bankCardBranchNo) {
        this.bankCardBranchNo = bankCardBranchNo;
    }

    public void setExistEmployeeIdentityAuthed(Boolean existEmployeeIdentityAuthed) {
        this.existEmployeeIdentityAuthed = existEmployeeIdentityAuthed;
    }
}
